using System.Linq;

namespace Kiwi.Container.Scope
{
    public class ComponentScope : IComponentScope
    {
        public static readonly IComponentScope Global = new ComponentScope(ContainerScope.Global);
        public static readonly IComponentScope HttpRequest = new ComponentScope(ContainerScope.HttpRequest);
        public static readonly IComponentScope HttpSession = new ComponentScope(ContainerScope.HttpSession);
        public static readonly IComponentScope Local = new AnyContainerComponentScope();
        public static readonly IComponentScope WcfRequest = new ComponentScope(ContainerScope.WcfRequest);

        private readonly IContainerScope[] _containerScopes;

        public ComponentScope(params IContainerScope[] containerScopes)
        {
            _containerScopes = containerScopes;
        }

        #region IComponentScope Members

        public bool IsCompatibleContainer(IContainerScope containerScope)
        {
            return _containerScopes.Contains(containerScope);
        }

        #endregion
    }
}